home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu247.dms / pu247.adf / Intuition / Gadgets / Example12.c < prev    next >
C/C++ Source or Header  |  1992-05-01  |  22KB  |  589 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE) V3.0      Amiga C Club (ACC) */
  4. /* -------------------------------      ------------------ */
  5. /*                                                         */
  6. /* Book:    ACM Intuition               Amiga C Club       */
  7. /* Chapter: Gadgets                     Tulevagen 22       */
  8. /* File:    Example12.c                 181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    92-05-01                                       */
  11. /* Version: 1.10                                           */
  12. /*                                                         */
  13. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This program will open a SuperBitmap window which is connected to the */
  21. /* Workbench Screen. The window will use all System Gadgets, and will    */
  22. /* close first when the user has selected the System gadget Close        */
  23. /* window. Inside the window we have put two Proportional gadgets, one   */
  24. /* on the right side, and one at the bottom. With help of these two      */
  25. /* gadgets, the user can move around the BitMap.                         */
  26. /*                                                                       */
  27. /* This example is for experienced programmers only, and uses some       */
  28. /* functions etc which we have not discussed yet. I have, however,       */
  29. /* included it here since it is a good example on how you can combine    */
  30. /* Proportional gadgets with SuperBitmap windows.                        */
  31.  
  32.  
  33.  
  34. #include <intuition/intuition.h>
  35.  
  36.  
  37.  
  38. #define WIDTH      320
  39. #define MAX_WIDTH  640
  40. #define HEIGHT     128
  41. #define MAX_HEIGHT 256
  42. #define DEPTH        2 /* 4 colours. */
  43.  
  44.  
  45.  
  46. /* Tell the C compiler that the function draw_some_boxes will return: */
  47. void draw_some_boxes(); /* Return nothing (void). */
  48.  
  49.  
  50.  
  51. /* Declare three pointers to the three libraries we are going to open: */
  52. struct IntuitionBase *IntuitionBase;
  53. struct GfxBase *GfxBase;
  54. struct LayersBase *LayersBase;
  55.  
  56.  
  57.  
  58. /***********************************************/
  59. /* THE RIGHT PROPORTIONAL GADGET's STRUCTURES: */
  60. /***********************************************/
  61.  
  62. /* We need to declare an Image structure for the knob, but since */
  63. /* Intuition will take care of the size etc of the knob, we do not need */
  64. /* to initialize the Image structure: */
  65. struct Image my_right_image;
  66.  
  67. struct PropInfo my_right_prop_info=
  68. {
  69.   FREEVERT|       /* Flags, the knob should be moved vertically, and */
  70.   AUTOKNOB,       /* Intuition should take care of the knob image. */
  71.   0,              /* HorizPot, 0 since we will not move the knob hor. */
  72.   0,              /* VertPot, start position of the knob. */
  73.   0,              /* HorizBody. 0 since we will not move the knob hor. */
  74.   MAXBODY * HEIGHT / MAX_HEIGHT, /* VertBody. */
  75.  
  76.   /* These variables are initialized and maintained by Intuition: */
  77.  
  78.   0,              /* CWidth */
  79.   0,              /* CHeight */
  80.   0, 0,           /* HPotRes, VPotRes */
  81.   0,              /* LeftBorder */
  82.   0               /* TopBorder */
  83. };
  84.  
  85. struct Gadget my_right_gadget=
  86. {
  87.   NULL,            /* NextGadget, no more gadgets in the list. */
  88.   -15,             /* LeftEdge, 15 pixels out from the right side. */
  89.     9,             /* TopEdge, 9 lines down. */
  90.    16,             /* Width, 16 pixels wide. */
  91.   -17,             /* Height, 17 lines less than the heigh of the wind. */
  92.   GADGHCOMP|       /* Flags, complement the colours when act. */
  93.   GRELRIGHT|       /* LeftEdge relative to the right border. */
  94.   GRELHEIGHT,      /* Height relative to the height of the window. */
  95.   GADGIMMEDIATE|   /* Activation, our program will recieve a message */
  96.   RELVERIFY|       /* when the user has selected this gadget, and when */
  97.                    /* the user has released it. We will also recieve a */ 
  98.   FOLLOWMOUSE,     /* message when the mouse moves while this gadget is */
  99.                    /* activated. */
  100.   PROPGADGET|      /* GadgetType, a Proportional gadget. */
  101.   GZZGADGET,       /* Put the gadget in the Outer window. */
  102.   (APTR) &my_right_image, /* GadgetRender, the knob's Image structure. */
  103.   NULL,            /* SelectRender, NULL since we do not supply the */
  104.                    /* gadget with an alternative image. */
  105.   NULL,            /* GadgetText, no text. */
  106.   NULL,            /* MutualExclude, no mutual exclude. */
  107.   (APTR) &my_right_prop_info, /* SpecialInfo, our PropInfo structure. */
  108.   0,               /* GadgetID, no id. */
  109.   NULL             /* UserData, no user data connected to the gadget. */
  110. };
  111.  
  112.  
  113.  
  114. /************************************************/
  115. /* THE BOTTOM PROPORTIONAL GADGET's STRUCTURES: */
  116. /************************************************/
  117.  
  118. /* We need to declare an Image structure for the knob, but since */
  119. /* Intuition will take care of the size etc of the knob, we do not need */
  120. /* to initialize the Image structure: */
  121. struct Image my_bottom_image;
  122.  
  123. struct PropInfo my_bottom_prop_info=
  124. {
  125.   FREEHORIZ|      /* Flags, the knob should be moved horizontally, and */
  126.   AUTOKNOB,       /* Intuition should take care of the knob image. */
  127.   0,              /* HorizPot, start position of the knob. */
  128.   0,              /* VertPot, 0 since we will not move the knob ver. */
  129.   MAXBODY * WIDTH / MAX_WIDTH, /* HorizBody. */
  130.   0,              /* VertBody, 0 since we will not move the knob ver. */
  131.  
  132.   /* These variables are initialized and maintained by Intuition: */
  133.  
  134.   0,              /* CWidth */
  135.   0,              /* CHeight */
  136.   0, 0,           /* HPotRes, VPotRes */
  137.   0,              /* LeftBorder */
  138.   0               /* TopBorder */
  139. };
  140.  
  141. struct Gadget my_bottom_gadget=
  142. {
  143.   &my_right_gadget,/* NextGadget, no more gadgets in the list. */
  144.     1,             /* LeftEdge, 1 pixel out from the left side. */
  145.    -8,             /* TopEdge, 8 lines above the bottom border. */
  146.   -15,             /* Width, 15 pixels less wide than the window. */
  147.     9,             /* Height, 9 lines heigh. */
  148.   GADGHCOMP|       /* Flags, complement the colours when act. */
  149.   GRELBOTTOM|      /* TopEdge relative to the bottom border. */
  150.   GRELWIDTH,       /* Width relative to the width of the window. */
  151.   GADGIMMEDIATE|   /* Activation, our program will recieve a message */
  152.   RELVERIFY|       /* when the user has selected this gadget, and when */
  153.                    /* the user has released it. We will also recieve a */ 
  154.   FOLLOWMOUSE|     /* message when the mouse moves while this gadget is */
  155.                    /* activated. */
  156.   BOTTOMBORDER,    /* Make the bottom border of the window big enough */
  157.                    /* for this gadge. */
  158.   PROPGADGET|      /* GadgetType, a Proportional gadget. */
  159.   GZZGADGET,       /* Put the gadget in the Outer window. */
  160.   (APTR) &my_bottom_image,/* GadgetRender, the knob's Image structure. */
  161.   NULL,            /* SelectRender, NULL since we do not supply the */
  162.                    /* gadget with an alternative image. */
  163.   NULL,            /* GadgetText, no text. */
  164.   NULL,            /* MutualExclude, no mutual exclude. */
  165.   (APTR) &my_bottom_prop_info, /* SpecialInfo, our PropInfo structure. */
  166.   0,               /* GadgetID, no id. */
  167.   NULL             /* UserData, no user data connected to the gadget. */
  168. };
  169.  
  170.  
  171.  
  172. /******************************/
  173. /* OPEN A SUPERBITMAP WINDOW: */
  174. /******************************/
  175.  
  176. /*************************************************************/
  177. /* 1. Declare and initialize a NewWindow structure with your */
  178. /*    requirements:                                          */
  179. /*************************************************************/
  180.  
  181. /* Declare a pointer to a Window structure: */ 
  182. struct Window *my_window;
  183.  
  184. /* Declare and initialize your NewWindow structure: */
  185. struct NewWindow my_new_window=
  186. {
  187.   10,            /* LeftEdge    x position of the window. */
  188.   30,            /* TopEdge     y positio of the window. */
  189.   WIDTH,         /* Width       200 pixels wide. */
  190.   HEIGHT,        /* Height      dsfsafsadfdsafsad50 lines high. */
  191.   0,             /* DetailPen   Text should be drawn with colour reg. 0 */
  192.   1,             /* BlockPen    Blocks should be drawn with colour reg. 1 */
  193.   CLOSEWINDOW|   /* IDCMPFlags  The window will give us a message if the */
  194.                  /*             user has selected the Close window gad, */
  195.   GADGETDOWN|    /*             or a gadget has been pressed on, or */
  196.   GADGETUP|      /*             a gadge has been released, or */
  197.   NEWSIZE|       /*             the user has changed the size or */
  198.   MOUSEMOVE,     /*             the mouse moved while a gadget was act. */
  199.   SUPER_BITMAP|  /* Flags       SuperBitMap. (No refreshing necessary) */
  200.   GIMMEZEROZERO| /*             It is also a Gimmezerozero window. */
  201.   WINDOWCLOSE|   /*             Close Gadget. */
  202.   WINDOWDRAG|    /*             Drag gadget. */
  203.   WINDOWDEPTH|   /*             Depth arrange Gadgets. */
  204.   WINDOWSIZING|  /*             Sizing Gadget. */
  205.   ACTIVATE,      /*             The window should be Active when opened. */
  206.   &my_bottom_gadget, /* FirstGadget  Pointer to the first gadget. */
  207.   NULL,          /* CheckMark   Use Intuition's default CheckMark (v). */
  208.   "SuperBitMap", /* Title       Title of the window. */
  209.   NULL,          /* Screen      Connected to the Workbench Screen. */
  210.   NULL,          /* BitMap      We will change this later. */
  211.   50,            /* MinWidth    We will not allow the window to become */
  212.   50,            /* MinHeight   smaller than 50 x 50, and not bigger */
  213.   MAX_WIDTH,     /* MaxWidth    than MAX_WIDTH x MAX_HEIGHT. */
  214.   MAX_HEIGHT,    /* MaxHeight */
  215.   WBENCHSCREEN   /* Type        Connected to the Workbench Screen. */
  216. };
  217.  
  218.  
  219.  
  220. /**********************************/
  221. /* 2. Declare a BitMap structure: */
  222. /**********************************/
  223.  
  224. struct BitMap my_bitmap;
  225.  
  226.  
  227.  
  228. main()
  229. {
  230.   /* Boolean variable used for the while loop: */
  231.   BOOL close_me;
  232.   
  233.   BOOL fix_window;
  234.  
  235.   int x, y;
  236.   int new_x, new_y; 
  237.   int delta_x, delta_y;
  238.  
  239.   /* Declare two pointers which the ScrollLayer() function needs: */
  240.   struct Layer *my_layer;
  241.   struct Layer_Info *my_layer_info;
  242.  
  243.   /* Declare a variable in which we will store the IDCMP flag: */
  244.   ULONG class;
  245.  
  246.   /* Declare a pointer to an IntuiMessage structure: */
  247.   struct IntuiMessage *my_message;
  248.  
  249.   /* Variable used for the loops: */
  250.   int loop;
  251.  
  252.  
  253.  
  254.   /* Before we can use Intuition we need to open the Intuition Library: */
  255.   IntuitionBase = (struct IntuitionBase *)
  256.     OpenLibrary( "intuition.library", 0 );
  257.   
  258.   if( IntuitionBase == NULL )
  259.     exit(); /* Could NOT open the Intuition Library! */
  260.  
  261.  
  262.  
  263.   /* Before we can use the function AllocRaster() etc we need to open */
  264.   /* the graphics Library. (See chapter "Amiga C" for more information) */
  265.   GfxBase = (struct GfxBase *)
  266.     OpenLibrary( "graphics.library", 0);
  267.  
  268.   if( GfxBase == NULL )
  269.   {
  270.     /* Could NOT open the Graphics Library! */
  271.  
  272.     /* Close the Intuition Library since we have opened it: */
  273.     CloseLibrary( IntuitionBase );
  274.  
  275.     exit();
  276.   }
  277.  
  278.  
  279.   /* Before we can use the function ScrollLayer() etc we need to open */
  280.   /* the layers Library. (See chapter "Amiga C" for more information) */
  281.   LayersBase = (struct LayersBase *)
  282.     OpenLibrary( "layers.library", 0);
  283.  
  284.   if( LayersBase == NULL )
  285.   {
  286.     /* Could NOT open the Layers Library! */
  287.  
  288.     /* Close the Graphics Library since we have opened it: */
  289.     CloseLibrary( GfxBase );
  290.  
  291.     /* Close the Intuition Library since we have opened it: */
  292.     CloseLibrary( IntuitionBase );
  293.  
  294.     exit();
  295.   }
  296.  
  297.  
  298.  
  299.   /**********************************************************/
  300.   /* 3. Initialize your own BitMap by calling the function: */
  301.   /**********************************************************/
  302.  
  303.   InitBitMap( &my_bitmap, DEPTH, MAX_WIDTH, MAX_HEIGHT );
  304.  
  305.   /* &my_bitmap: A pointer to the my_bitmap structure. */
  306.   /* DEPTH:      Number of bitplanes to use. */
  307.   /* MAX_WIDTH:  The width of the BitMap. */
  308.   /* MAX_HEIGHT: The height of the BitMap. */
  309.  
  310.  
  311.  
  312.   /**********************************************/
  313.   /* 4. Allocate display memory for the BitMap: */
  314.   /**********************************************/
  315.  
  316.   for( loop=0; loop < DEPTH; loop++)
  317.     if((my_bitmap.Planes[loop] = (PLANEPTR)
  318.       AllocRaster( MAX_WIDTH, MAX_HEIGHT )) == NULL )
  319.     {
  320.       /* PANIC! Not enough memory */
  321.  
  322.       /* Deallocate the display memory, Bitplan by Bitplan. */ 
  323.       for( loop=0; loop < DEPTH; loop++)
  324.         if( my_bitmap.Planes[loop] ) /* Deallocate this Bitplan? */
  325.           FreeRaster( my_bitmap.Planes[loop], MAX_WIDTH, MAX_HEIGHT );
  326.  
  327.       /* Close the Layers Library since we have opened it: */
  328.       CloseLibrary( LayersBase );
  329.  
  330.       /* Close the Graphics Library since we have opened it: */
  331.       CloseLibrary( GfxBase );
  332.  
  333.       /* Close the Intuition Library since we have opened it: */
  334.       CloseLibrary( IntuitionBase );
  335.  
  336.       exit();
  337.     }
  338.  
  339.  
  340.  
  341.   /***************************/
  342.   /* 5. Clear all Bitplanes: */
  343.   /***************************/
  344.   
  345.   for( loop=0; loop < DEPTH; loop++)
  346.     BltClear( my_bitmap.Planes[loop], RASSIZE( MAX_WIDTH, MAX_HEIGHT ), 0);
  347.  
  348.   /* The memory we allocated for the Bitplanes, is normaly "dirty", and */
  349.   /* therefore needs cleaning. We can here use the Blitter to clear the */
  350.   /* memory since it is the fastest way to do it, and the easiest. */
  351.   /* RASSIZE is a macro which calculates memory size for a Bitplane of */
  352.   /* the size WIDTH x HEIGHT. We will later go into more details about */
  353.   /* these functions etc, so do not worry about them... yet. */
  354.  
  355.  
  356.  
  357.   /*******************************************************************/
  358.   /* 6. Make sure the NewWindow's BitMap pointer is pointing to your */
  359.   /*    BitMap structure:                                            */
  360.   /*******************************************************************/
  361.  
  362.   my_new_window.BitMap=&my_bitmap;
  363.  
  364.  
  365.  
  366.   /***************************************/
  367.   /* 7. At last you can open the window: */
  368.   /***************************************/
  369.  
  370.   my_window = (struct Window *) OpenWindow( &my_new_window );
  371.  
  372.   /* Have we opened the window succesfully? */
  373.   if(my_window == NULL)
  374.   {
  375.     /* Could NOT open the Window! */
  376.  
  377.     /* Deallocate the display memory, Bitplan by Bitplan. */ 
  378.     for( loop=0; loop < DEPTH; loop++)
  379.       if( my_bitmap.Planes[loop] ) /* Deallocate this Bitplan? */
  380.         FreeRaster( my_bitmap.Planes[loop], MAX_WIDTH, MAX_HEIGHT );
  381.  
  382.     /* Close the Layers Library since we have opened it: */
  383.     CloseLibrary( LayersBase );
  384.  
  385.     /* Close the Graphics Library since we have opened it: */
  386.     CloseLibrary( GfxBase );
  387.  
  388.     /* Close the Intuition Library since we have opened it: */
  389.     CloseLibrary( IntuitionBase );
  390.  
  391.     exit();
  392.   }
  393.  
  394.  
  395.  
  396.   /* We have opened the window, and everything seems to be OK. */
  397.  
  398.  
  399.   
  400.   /* Initialize the two pointers which will be used by the ScrollLayer */
  401.   /* function: */
  402.   my_layer_info=&(my_window->WScreen->LayerInfo);
  403.   my_layer=my_window->RPort->Layer;
  404.  
  405.  
  406.  
  407.   /* We will now draw some boxes in different colours: */
  408.   draw_some_boxes();
  409.  
  410.  
  411.  
  412.   /* We can for the moment see the top left corner of the BitMap: */
  413.   x=0;
  414.   y=0;
  415.  
  416.   /* The window does not need to be redrawn: */
  417.   fix_window=FALSE;
  418.   
  419.   /* The user wants to run the program for the momnt. */
  420.   close_me = FALSE;
  421.  
  422.   /* Stay in the while loop until the user has selected the Close window */
  423.   /* gadget: */
  424.   while( close_me == FALSE )
  425.   {
  426.     /* Wait until we have recieved a message: */
  427.     Wait( 1 << my_window->UserPort->mp_SigBit );
  428.  
  429.     /* We have now recieved one or more messages. */
  430.  
  431.     /* Since we may recieve several messages we stay in the while loop */
  432.     /* and collect, save, reply and execute the messages until there is */
  433.     /* a pause: */
  434.     while(my_message=(struct IntuiMessage *)GetMsg( my_window->UserPort))
  435.     {
  436.       /* GetMsg will return a pointer to a message if there was one, */
  437.       /* else it returns NULL. We will therefore stay in this while loop */
  438.       /* as long as there are some messages waiting in the port. */
  439.       
  440.       /* After we have collected the message we can read it, and save */
  441.       /* any important values which we maybe want to check later: */
  442.       class = my_message->Class;      /* Save the IDCMP flag. */
  443.  
  444.       /* After we have read it we reply as fast as possible: */
  445.       /* REMEMBER! Do never try to read a message after you have replied! */
  446.       /* Some other process has maybe changed it. */
  447.       ReplyMsg( my_message );
  448.  
  449.       /* Check which IDCMP flag was sent: */
  450.       switch( class )
  451.       {
  452.         case CLOSEWINDOW:  /* The user selected the Close window gadget! */
  453.                close_me=TRUE;
  454.                break;
  455.  
  456.         case MOUSEMOVE:    /* The user moved the mouse while one of the */
  457.                            /* Proportional gadgets was activated: */ 
  458.                fix_window=TRUE; /* Redraw the display. */
  459.                break;             
  460.  
  461.         case NEWSIZE:      /* The user has resized the window: */
  462.                /* Change size of the knobs: */
  463.                ModifyProp
  464.                (
  465.                  &my_right_gadget,           /* Pointer to the gadget. */
  466.                  my_window,                  /* Pointer to the window. */
  467.                  NULL,                       /* Not a requester gadget. */
  468.                  my_right_prop_info.Flags,   /* Flags, no change. */
  469.                  0,                          /* HorizPot */
  470.                  my_right_prop_info.VertPot, /* VertPot, no change. */
  471.                  0,                          /* HorizBody */
  472.                                              /* VertBody: */
  473.                  (ULONG) MAXBODY*my_window->Height/MAX_HEIGHT
  474.                );
  475.                ModifyProp
  476.                (
  477.                  &my_bottom_gadget,            /* Pointer to the gadget. */
  478.                  my_window,                    /* Pointer to the window. */
  479.                  NULL,                         /* Not a req. gadget. */
  480.                  my_bottom_prop_info.Flags,    /* Flags, no change. */
  481.                  my_bottom_prop_info.HorizPot, /* HorizPot, no change. */
  482.                  0,                            /* VertPot */
  483.                                                /* HorizBody: */
  484.                  (ULONG) MAXBODY*my_window->Width/MAX_WIDTH,
  485.                  0                             /* VertBody: */
  486.                );
  487.                fix_window=TRUE; /* Redraw the display. */
  488.                break;
  489.         
  490.         case GADGETDOWN:   /* The user has selected one of the gadgets: */
  491.                fix_window=TRUE; /* Redraw the display. */
  492.                break;
  493.              
  494.         case GADGETUP:     /* The user has released one of the gadgets: */
  495.                fix_window=TRUE; /* Redraw the display. */
  496.                break;
  497.       }    
  498.     }
  499.  
  500.  
  501.  
  502.     /* Should we update the window's display? */
  503.     if(fix_window)
  504.     {
  505.       fix_window=FALSE;
  506.             
  507.       /* Calculate what part of the BitMap we should display: */
  508.       new_x= (MAX_WIDTH - my_bottom_prop_info.HorizBody / (float) MAXBODY
  509.              * MAX_WIDTH) * my_bottom_prop_info.HorizPot / (float) MAXPOT;
  510.  
  511.       new_y= (MAX_HEIGHT - my_right_prop_info.VertBody / (float) MAXBODY
  512.              * MAX_HEIGHT) * my_right_prop_info.VertPot / (float) MAXPOT;
  513.  
  514.       delta_x=new_x-x;
  515.       delta_y=new_y-y;
  516.  
  517.       x=new_x;
  518.       y=new_y;
  519.  
  520.       ScrollLayer( my_layer_info, my_layer, delta_x, delta_y );
  521.     }
  522.   }
  523.  
  524.  
  525.  
  526.   /********************************************************************/
  527.   /* 8. Do not forget to close the window, AND deallocate the display */
  528.   /*    memory:                                                       */
  529.   /********************************************************************/
  530.  
  531.   /* We should always close the windows we have opened before we leave: */
  532.   CloseWindow( my_window );
  533.  
  534.   /* Deallocate the display memory, Bitplan by Bitplan. */ 
  535.   for( loop=0; loop < DEPTH; loop++)
  536.     if( my_bitmap.Planes[loop] ) /* Deallocate this Bitplan? */
  537.       FreeRaster( my_bitmap.Planes[loop], MAX_WIDTH, MAX_HEIGHT );
  538.  
  539.  
  540.  
  541.   /* Close the Layers Library since we have opened it: */
  542.   CloseLibrary( LayersBase );
  543.  
  544.   /* Close the Graphics Library since we have opened it: */
  545.   CloseLibrary( GfxBase );
  546.  
  547.   /* Close the Intuition Library since we have opened it: */
  548.   CloseLibrary( IntuitionBase );
  549.   
  550.   /* THE END */
  551. }
  552.  
  553.  
  554.  
  555. /* This function draws some coloured boxes: */
  556. /* Returns nothing. */
  557. void draw_some_boxes()
  558. {
  559.   int x, y;
  560.   UBYTE colour;
  561.   
  562.  
  563.   colour=1; /* Set colour to 1, white. */
  564.  
  565.   /* Set Draw Mode to normal: */
  566.   SetDrMd( my_window->RPort, JAM1 );
  567.   
  568.   for(x=0; x < MAX_WIDTH/40-2; x++)
  569.     for(y=0; y < MAX_HEIGHT/20-2; y++)
  570.     {
  571.       /* New colour to draw with */
  572.       SetAPen( my_window->RPort, colour );
  573.  
  574.       colour++;
  575.  
  576.       /* If colour is bigger than 3 (Orange) we change colour to 1 */
  577.       /* (white) again. (The boxes will therefore be drawn with the */
  578.       /* colours white, black, orange: */
  579.       if(colour > 3)
  580.         colour=1;
  581.     
  582.       Move( my_window->RPort, x*40+40, y*20+20 ); /* Top left corner. */
  583.       Draw( my_window->RPort, x*40+72, y*20+20 ); /* Out to the right. */
  584.       Draw( my_window->RPort, x*40+72, y*20+36 ); /* Down. */
  585.       Draw( my_window->RPort, x*40+40, y*20+36 ); /* Back to the left. */
  586.       Draw( my_window->RPort, x*40+40, y*20+20 ); /* Up again. */    
  587.     }
  588. }
  589.